#ifndef RECBOXITEM_H
#define RECBOXITEM_H

#include <QWidget>
#include <QNetworkAccessManager>
#include <QNetworkReply>
#include<QStandardPaths>
#include<QCryptographicHash>
#include<QDir>
#include<QFile>
#include<musiclist.h>


extern QMap<QString,QPixmap> g_cover_cache;//全局静态缓存

namespace Ui {
class RecBoxItem;
}

class RecBoxItem : public QWidget
{
    Q_OBJECT

public:
    explicit RecBoxItem(QWidget *parent = nullptr);
    ~RecBoxItem();

    //设置推荐文本
    void setRecText(const QString&text);

    //设置图片
    void setRecImage(const QString& imagePath);

    bool eventFilter(QObject*watched,QEvent *event);

private slots:
    void on_recMusicBtn_clicked();

    void onMusicListReply(QNetworkReply *reply, const QString &listName);

private:
    Ui::RecBoxItem *ui;
    QNetworkAccessManager *manager=nullptr;

    QString cacheFilePath(const QString &url);//将网络图片转化为本地缓存

    MusicList netList;

    QString cover_path;


signals:
    void netMusicListready(MusicList,QString);

};

#endif // RECBOXITEM_H
